// pages/client/client.js
Page({
  data: {
    navData: [{
      name: "首页",
      current: 0,
      style: 0,
      ico: 'icon-deng',
      fn: 'navJumpPage',
      id: '/pages/home/home'
    }, {
      name: "客户",
      current: 0,
      style: 0,
      ico: 'icon-guanlikehu',
      fn: 'navJumpPage',
      id: '/pages/client/client'
    }, {
      name: "添加汇报",
      current: 0,
      style: 1,
      ico: '',
      fn: 'navJumpPage',
      id: '/pages/addReport/addReport'
    }, {
      name: "工作汇报",
      current: 0,
      style: 0,
      ico: 'icon-xiebaogao',
      fn: 'navJumpPage',
      id: '/pages/report/report'
    }, {
      name: "我的",
      current: 1,
      style: 0,
      ico: 'icon-dkw_wode',
      fn: 'navJumpPage',
      id: ''
    }],
    postFlag:false
  },
  navJumpPage(event) {
    let url = event.currentTarget.id;
    if (url) {
      if (url === '/pages/addReport/addReport') {
        wx.navigateTo({
          url: url
        });
      } else {
        wx.redirectTo({
          url: url
        });
      }
    }
  },
  actionSheetTap () {
    wx.showActionSheet({
      itemList: ['去签到', '查看签到记录'],
      success: function (e) {
        console.log(e.tapIndex)
        let url = '',index = e.tapIndex;
        index === 0 ? url = '/pages/signIn/signIn' : url = '/pages/signInList/signInList';
        wx.navigateTo({
          url: url
        });
      }
    })
  },
  jumpPage(e){
    let url = '';
    if (e.currentTarget.id==='shenhe'){
      url ='/pages/auditOrder/auditOrder';
    } else if (e.currentTarget.id ==='shenhezhuguan'){
      url = '/pages/salesmanOrder/salesmanOrder';
    }else{
      url ='/pages/clientOrder/clientOrder';
    }
      wx.navigateTo({url:url});
  },
  onLoad() {
    let that = this;
    wx.getStorage({
      key: 'post',
      success(res) {
        let postFlag = false;
        res.data === '部门主管' ? postFlag = true : postFlag = false;
        that.setData({
          postFlag: postFlag
        });
      }
    });
  },
})